﻿<!--***********************************************************************************

   Extended WPF Toolkit

   Copyright (C) 2007-2013 Xceed Software Inc.

   This program is provided to you under the terms of the Microsoft Public
   License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license 

   For more features, controls, and fast professional support,
   pick up the Plus Edition at http://xceed.com/wpf_toolkit

   Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids

  **********************************************************************************-->

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:Xceed.Wpf.DataGrid"
                    xmlns:views="clr-namespace:Xceed.Wpf.DataGrid.Views"
                    xmlns:conv="clr-namespace:Xceed.Wpf.DataGrid.Converters">

   <Style TargetType="{x:Type views:TableViewScrollViewer}">

      <Setter Property="VerticalScrollBarVisibility"
              Value="Visible" />

      <Setter Property="HorizontalScrollBarVisibility"
              Value="{Binding HorizontalScrollBarVisibilityHint, RelativeSource={RelativeSource Self}}" />

      <Setter Property="CanContentScroll"
              Value="True" />

      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type views:TableViewScrollViewer}">

               <!-- Root Grid that layout the "content" and the Scrollbars -->
               <Grid>
                  <Grid.ColumnDefinitions>
                     <!-- Content -->
                     <ColumnDefinition />

                     <!-- Vertical ScrollBar -->
                     <ColumnDefinition Width="Auto" />
                  </Grid.ColumnDefinitions>

                  <Grid.RowDefinitions>
                     <!-- Content -->
                     <RowDefinition />

                     <!-- Horizontal ScrollBar -->
                     <RowDefinition Height="Auto" />
                  </Grid.RowDefinitions>

                  <!-- Content -->

                  <Grid Margin="{TemplateBinding Padding}">
                     <Grid.ColumnDefinitions>
                        <!-- RowSelectorPane-->
                        <ColumnDefinition Width="Auto" />

                        <!-- ScrollContentPresenter -->
                        <ColumnDefinition />
                     </Grid.ColumnDefinitions>

                     <Grid.RowDefinitions>
                        <!-- Fixed Headers -->
                        <RowDefinition Height="Auto" />

                        <!-- ScrollContentPresenter -->
                        <RowDefinition />

                        <!-- Fixed Footers -->
                        <RowDefinition Height="Auto" />
                     </Grid.RowDefinitions>

                     <!-- RowSelectorPane -->

                     <local:RowSelectorPane x:Name="PART_RowSelectorPane"
                                            Grid.Column="0"
                                            Grid.Row="0"
                                            Grid.RowSpan="3"
                                            Width="{TemplateBinding RowSelectorPaneWidth}" />

                     <!-- Fixed Headers -->

                     <views:SynchronizedScrollViewer x:Name="fixedHeaderScrollViewer"
                                                     Grid.Column="1"
                                                     Grid.Row="0"
                                                     views:TableViewScrollViewer.SynchronizedScrollViewerPosition="Top"
                                                     Focusable="False">
                        <!-- Using a TableViewHeaderFooterPanel will enable the columns 
                             auto width feature. -->
                        <views:TableViewHeaderFooterPanel local:DataGridControl.IsFixedHeadersHost="True"
                                                          Orientation="Vertical"
                                                          HorizontalAlignment="Left" />

                     </views:SynchronizedScrollViewer>

                     <!-- Fixed Footers -->

                     <views:SynchronizedScrollViewer  x:Name="fixedFooterScrollViewer"
                                                      Grid.Column="1"
                                                      Grid.Row="2"
                                                      views:TableViewScrollViewer.SynchronizedScrollViewerPosition="Bottom"
                                                      Focusable="False">
                        <!-- Using a TableViewHeaderFooterPanel will enable the columns 
                             auto width feature. -->
                        <views:TableViewHeaderFooterPanel local:DataGridControl.IsFixedFootersHost="True"
                                                          Orientation="Vertical"
                                                          HorizontalAlignment="Left" />

                     </views:SynchronizedScrollViewer>

                     <!-- ScrollContentPresenter (data rows) -->

                     <ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
                                             Grid.Column="1"
                                             Grid.Row="1"
                                             CanContentScroll="{TemplateBinding CanContentScroll}" />

                  </Grid>

                  <!-- ScrollBars -->

                  <ScrollBar x:Name="PART_HorizontalScrollBar"
                             Grid.Column="0"
                             Grid.Row="1"
                             Orientation="Horizontal"
                             Maximum="{TemplateBinding ScrollViewer.ScrollableWidth}"
                             Value="{TemplateBinding ScrollViewer.HorizontalOffset}"
                             ViewportSize="{TemplateBinding ScrollViewer.ViewportWidth}"
                             Visibility="{TemplateBinding ScrollViewer.ComputedHorizontalScrollBarVisibility}" />

                  <ScrollBar x:Name="PART_VerticalScrollBar"
                             Grid.Column="1"
                             Grid.Row="0"
                             Orientation="Vertical"
                             Maximum="{TemplateBinding ScrollViewer.ScrollableHeight}"
                             Value="{TemplateBinding ScrollViewer.VerticalOffset}"
                             ViewportSize="{TemplateBinding ScrollViewer.ViewportHeight}"
                             Visibility="{TemplateBinding ScrollViewer.ComputedVerticalScrollBarVisibility}" />

                  <!-- ScrollTip only displayed when scrolling -->
                  <local:ScrollTip Visibility="Collapsed"
                                   Content="{x:Null}"
                                   ContentTemplate="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).ScrollTipContentTemplate}"
                                   ContentTemplateSelector="{Binding RelativeSource={RelativeSource Self}, Path=(local:DataGridControl.DataGridContext).ScrollTipContentTemplateSelector}" />

               </Grid>

               <ControlTemplate.Triggers>
                  <Trigger Property="ShowRowSelectorPane"
                           Value="False">

                     <Setter TargetName="PART_RowSelectorPane"
                             Property="Visibility"
                             Value="Collapsed" />
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

</ResourceDictionary>
